package com.hfb.mashibing.alip8.juc.c006;

/**
 * synchronized 和 volatile 没必要同时加
 * 对某个对象加锁
 */
public class T implements Runnable {

    private /*volatile*/ int count = 100;

    public synchronized void run() {
        count --;
        System.out.println(
                Thread.currentThread().getName() +
                " count=" + count);

    }

    public static void main(String[] args) {
        T t = new T();
        for (int i = 0; i < 100; i++) {
            new Thread(t, "thread"+i).start();
        }
    }
}
